package Views;

import Dao.NoPara;
import Dao.ShowColumns;
import Model.StudentCourse;

import java.util.ArrayList;

/**
 * 显示所有学生信息，倒序输出
 * @author 张世豪
 */
public class AllStudentView {
    private NoPara noPara = new NoPara();
    private ShowColumns showColumns = new ShowColumns();
    /**
     * 显示所有学生成绩，按降序排列
     *
     */
    public void mainView() {
        ArrayList<StudentCourse> studentList = noPara.selectAll();
        ArrayList<String> courses= showColumns.showColumns();
        System.out.print("         ");
        for (String courseName:courses) {
            System.out.print(courseName+" ");
        }
        System.out.println("");
        for (StudentCourse studentCourse : studentList) {
            System.out.print(studentCourse.getName()+"      ");//打印姓名
            for (int course : studentCourse.getCourseList()) {
                System.out.print(course+"     ");//打印每门课程成绩
            }
            System.out.println("");//换行

        }
        MainPage mainPage = new MainPage();
        mainPage.mainMenu();

    }
}
